import { createApp } from 'vue'
import { createPinia } from 'pinia'
import 'element-plus/dist/index.css'

import ElementPlus from 'element-plus'
import App from './App.vue'
import router from './router'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const app = createApp(App)
const pinia = createPinia()

app.use(pinia)


app.use(ElementPlus, { size: 'small', zIndex: 3000 })
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

function generatePastelColor() {
  const hue = Math.floor(Math.random() * 360); // 色相：0-360
  return `hsl(${hue}, 70%, 85%)`; // 饱和度较低，亮度较高，柔和
}

app.directive('random-bg', {
  mounted(el) {
/*     const randomColor1 = '#' + Math.floor(Math.random() * 16777215).toString(16).padStart(6, '0');
    const randomColor2 = '#' + Math.floor(Math.random() * 16777215).toString(16).padStart(6, '0'); */

    const randomColor1 = generatePastelColor();
    const randomColor2 = generatePastelColor();
    el.style.background = `linear-gradient(to right, ${randomColor1}, ${randomColor2})`;
  }
});

app.use(router)
app.mount('#app')
